package com.ruoyi.tree_test.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tree_test.domain.DeviceInfoTest;
import com.ruoyi.tree_test.service.IDeviceInfoTestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.tree_test.domain.vo.DeviceInfoTestVo;

/**
 * 设备信息测试Controller
 * 
 * @author ruoyi
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/test/device_info_test")
public class DeviceInfoTestController extends BaseController
{
    @Autowired
    private IDeviceInfoTestService deviceInfoTestService;

    /**
     * 查询设备信息测试列表
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceInfoTest deviceInfoTest)
    {
        startPage();
        List<DeviceInfoTest> list = deviceInfoTestService.selectDeviceInfoTestList(deviceInfoTest);
        return getDataTable(list);
    }
    
    /**
     * 查询设备信息测试列表（包含地理位置名称）
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:list')")
    @GetMapping("/listWithLocation")
    public TableDataInfo listWithLocation(DeviceInfoTest deviceInfoTest) {
        startPage();
        List<DeviceInfoTestVo> list = deviceInfoTestService.selectDeviceInfoTestVoList(deviceInfoTest);
        return getDataTable(list);
    }


    /**
     * 导出设备信息测试列表
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:export')")
    @Log(title = "设备信息测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInfoTest deviceInfoTest)
    {
        List<DeviceInfoTest> list = deviceInfoTestService.selectDeviceInfoTestList(deviceInfoTest);
        ExcelUtil<DeviceInfoTest> util = new ExcelUtil<DeviceInfoTest>(DeviceInfoTest.class);
        util.exportExcel(response, list, "设备信息测试数据");
    }

    /**
     * 获取设备信息测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(deviceInfoTestService.selectDeviceInfoTestByDeviceId(deviceId));
    }

    /**
     * 新增设备信息测试
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:add')")
    @Log(title = "设备信息测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceInfoTest deviceInfoTest)
    {
        return toAjax(deviceInfoTestService.insertDeviceInfoTest(deviceInfoTest));
    }

    /**
     * 修改设备信息测试
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:edit')")
    @Log(title = "设备信息测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceInfoTest deviceInfoTest)
    {
        return toAjax(deviceInfoTestService.updateDeviceInfoTest(deviceInfoTest));
    }

    /**
     * 删除设备信息测试
     */
    @PreAuthorize("@ss.hasPermi('test:device_info_test:remove')")
    @Log(title = "设备信息测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(deviceInfoTestService.deleteDeviceInfoTestByDeviceIds(deviceIds));
    }
}
